package frontend.pages.admin.sfi;

import backend.model.admin.Sfi;
import backend.service.admin.SfiService;
import frontend.core.TimeTrackingWebApplication;
import frontend.model.admin.SfiUIModel;
import frontend.pages.admin.base.AbstractManagingPage;
import org.apache.wicket.markup.html.panel.Panel;
import org.wicketstuff.annotation.mount.MountPath;

import java.util.List;

@MountPath("sfi")
public class SfiManagingPage extends AbstractManagingPage<Sfi> {

	public SfiManagingPage() {
		super("pages.admin.sfi.title", "contextualHelp.admin.sfi.text");
	}

    @Override
    protected String getAddPanelTitleKey() {
        return "pages.admin.sfi.add.title";
    }

    @Override
    protected String getEditPanelTitleKey() {
        return "pages.admin.sfi.edit.title";
    }

    @Override
    protected String getNoSelectionMessageKey() {
        return "pages.admin.sfi.edit.noSelection";
    }

    @Override
    protected Panel getAddPanel(String panelId) {
        return new SfiPanel(panelId, getPageParameters(), new SfiUIModel());
    }

    @Override
    protected Panel getEditPanel(String panelId, Sfi sfi) {
        getPageParameters().clearNamed();
        return new SfiPanel(panelId, null, new SfiUIModel(sfi));
    }

    @Override
    public List<Sfi> loadAvailableEntities() {
        SfiService sfiService = TimeTrackingWebApplication.getService(SfiService.class);
        return sfiService.findAllSfis();
    }
}
